package com.ruoyi.system.domain;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
@TableName("pm_material_list")
@ApiModel(value = "PmMaterialList对象", description = "项目物料清单主表（关联t_project）")
public class PmMaterialList  {

    @ApiModelProperty(value = "清单ID（自增主键）", example = "1")
    @TableId(type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "关联项目ID（关联t_project.id）", example = "100")
    @TableField("project_id")
    private Long projectId;

    @ApiModelProperty(value = "项目编号（冗余t_project.project_no）", example = "XM20250914001")
    @TableField("project_no")
    private String projectNo;

    @ApiModelProperty(value = "项目名称（冗余t_project.project_name）", example = "阳光花园3栋101")
    @TableField("project_name")
    private String projectName;

    @ApiModelProperty(value = "物料清单名称", example = "阳光花园3栋101-物料清单")
    @TableField("list_name")
    private String listName;

    @ApiModelProperty(value = "清单状态", allowableValues = "0,1,2,3",
            notes = "0=未创建，1=已创建，2=已推送，3=已确认", example = "1")
    @TableField("list_status")
    private Integer listStatus;

    @ApiModelProperty(value = "业主预算（元）", example = "100000.00")
    @TableField("owner_budget")
    private BigDecimal ownerBudget;

    @ApiModelProperty(value = "预算总额（元）", example = "95000.50")
    @TableField("budget_total")
    private BigDecimal budgetTotal;

    @ApiModelProperty(value = "总成本（元）", example = "76000.20")
    @TableField("cost_total")
    private BigDecimal costTotal;

    @ApiModelProperty(value = "毛利率（%）", example = "20.0")
    @TableField("gross_margin")
    private BigDecimal grossMargin;

    @ApiModelProperty(value = "创建人ID（关联sys_user.id）", example = "1")
    @TableField("create_user_id")
    private Long createUserId;

    @ApiModelProperty(value = "创建人姓名", example = "张三")
    @TableField("create_user_name")
    private String createUserName;

    @ApiModelProperty(value = "备注", example = "用于2025年8月业主预算沟通")
    @TableField("remark")
    private String remark;

    // 非数据库字段：物料总数（列表展示用）
    @ApiModelProperty(value = "物料总数（项）", example = "20")
    @TableField(exist = false)
    private Integer materialCount;

    /**
     * 逻辑删除标识：0-未删除，1-已删除
     */
    @TableField("deleted")
    @TableLogic
    private Integer deleted;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @TableField(exist = false)
    private List<PmMaterialItem> items;

    /**
     * H5用户ID
     * 绑定的H5账号用户ID，绑定后才有值
     */
    @TableField(value = "h5_user_id", exist = false)
    private Long h5UserId;


    /**
     * H5用户名
     * 绑定的H5账号用户名
     */
    @TableField(value = "h5_user_name", exist = false)
    private String h5UserName;


    /**
     * 创建开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField( exist = false)
    private LocalDate createTimeStart;

    /**
     * 创建结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField( exist = false)
    private LocalDate createTimeEnd;
}
